<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
	<script type="text/javascript" src="//api.map.baidu.com/getscript?type=webgl&v=1.0&ak=sZa7RLArCMJQVdNcwPexKS56FxpyXxU6"></script>
    <title>根据多关键字本地搜索</title>
    <style type="text/css">
		body, html,#allmap {width: 100%;height: 100%; margin:0;font-family:"微软雅黑";}
		#l-map{height:300px;width:100%;}
		#r-result{width:100%;}
	</style>
</head>
<body>
	<div id="l-map"></div>
	<div id="r-result"></div>
</body>
</html>
<script type="text/javascript">
	// 百度地图API功能
	var t_map = new BMapGL.Map("l-map");            // 创建Map实例
	var t_point = new BMapGL.Point(116.404, 39.915);   
	var t_marker = new BMapGL.Marker(t_point);        // 创建标注   
	t_map.addOverlay(t_marker);                     // 将标注添加到地图中
	t_marker.addEventListener("click", function(){   
		alert("您点击了标注");   
	});

	// 多边形
	var t_polygon = new BMapGL.Polygon([
		new BMapGL.Point(116.387112,39.920977),
		new BMapGL.Point(116.385243,39.913063),
		new BMapGL.Point(116.41248,39.917893)
	], {strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5});
	t_map.addOverlay(t_polygon);

	// 折线
	var t_polyline = new BMapGL.Polyline([
			new BMapGL.Point(116.399, 39.910),
			new BMapGL.Point(116.405, 39.920),
			new BMapGL.Point(116.425, 39.900)
		], {strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5});
	t_map.addOverlay(t_polyline);

	t_map.centerAndZoom(t_point, 15);
	t_map.enableScrollWheelZoom(true);
	
	// // 解析地址
	// var myGeo = new BMapGL.Geocoder();
	// // 将地址解析结果显示在地图上，并调整地图视野
	// myGeo.getPoint('北京市海淀区上地10街', function(p_point){
	// 	if(p_point){
	// 		t_map.centerAndZoom(p_point, 16);
	// 		t_map.addOverlay(new BMapGL.Marker(point, {title: '北京市海淀区上地10街'}))
	// 	}else{
	// 		alert('您选择的地址没有解析到结果！');
	// 	}
	// }, '北京市');

	// 搜索地址
	var myKeys = ["故宫", "国家大剧院"];
	var local = new BMapGL.LocalSearch(t_map, {
		renderOptions:{map: t_map, panel:"r-result"},
		pageCapacity:5
	});
	local.setLocation(t_point);
	local.searchInBounds(myKeys, t_map.getBounds());
</script>

<style>
    .anchorBL {display: none}
</style>